package thread;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * 根据机器性能和堆内存等有关
 * @author jiangwz
 * @create 2019/9/29.
 */
public class TestThreadMaxNum {

    public static void main(String[] args){
        AtomicInteger atomicInteger = new AtomicInteger();
        for (int i = 0; i < Integer.MAX_VALUE; i++) {
//        for (int i = 0; i < 10000; i++) {
            new Thread(() ->{
                try {
                    int j = atomicInteger.incrementAndGet();
                    System.out.println(Thread.currentThread().getName() + " : "+j);
                    TimeUnit.SECONDS.sleep(60);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            },""+i).start();
        }
    }
}
